import React from 'react';
import ImageLazy from '../commons/ImageLazy';
import NavLink from '../commons/NavLink';
import { connect } from 'react-redux';
import {mall_them_hos_servItem} from '../../actions';
import {getHosImg,getDocImg,getServImg} from '../../actions/ActionTypes';

const mall_vip = require('!url?limit=8192&name=static/img/[hash:6].[ext]!../../static/img/mall_vip.png');

let mydefault = React.createClass({
  componentDidMount:function(){
      const {dispatch} = this.props;
      dispatch(mall_them_hos_servItem({pageSize:20,pageNo:1}));
  },
  render:function(){
    let mall_them_hos_servItem = this.props.mall_them_hos_servItem || [];
        // console.log(itemPro)
    return(
      <div className="m_pro_list">
        <div className="item_wrapp">
        {
          mall_them_hos_servItem.map(function(item,index){
            if(item.typeId == '3'){
              let imgSrc = getServImg(item.itemImage,'_200_200',item.hospitalId,item.itemId)
                return(
                  <NavLink to={"/servItem/det/" + item.itemId} className="common_item border_b1">
                    <div className="left">
                      {/* <em style={{"background-image":"url("+ imgSrc + ")"}}></em> */}
                      <img src={imgSrc} style={{height:'1rem','width':'1.38rem'}} />
                    </div>
                    <div className="right">
                      <h4>{item.itemName} {item.doctorName} {item.icName}</h4>
                      <p>
                        {item.hospitalName} <ImageLazy src={mall_vip} style={{"width":".28rem"}} />
                      </p>
                      <div className="price"><span>¥ {item.sellingPrice}</span></div><s className="o_price">¥ {item.originalPrice}</s>
                    </div>
                  </NavLink>
                )
              }
          })
        }

        </div>
      </div>
    )
  }
})

let mapStateToProps = (state,own) => {
    let mall_them_hos_servItem = state.mall.mall_them_hos_servItem || [];
  return{
    mall_them_hos_servItem,
    // typeId:own.params.id
  }
}

export default connect(mapStateToProps)(mydefault);
